
package de.osmembrane.tools.integrity_test;

import java.io.FileNotFoundException;

import javax.xml.bind.JAXBException;

/**
 * The integrity test checks a given osmembrane xml file for integrity.
 * 
 * @author jakob_jarosch
 */
public class Main {

	public static void main(String[] args) {
		if (args.length != 1) {
			System.out.println("Usage: java -jar omsois-xml-integrity-test.jar <xml-filename>");
			System.exit(1);
		}
		
		IntegrityTest test = null;
		try {
			test = new IntegrityTest(args[0]);
		} catch (FileNotFoundException e) {
			System.out.println("The file can't be read: " + e.getMessage());
			System.exit(1);
		}

		
		try {
			test.loadXML();
		} catch (JAXBException e) {
			System.out.println("The XML-file could not be parsed successfully: ");
			e.printStackTrace();
			System.exit(1);
		}
		
		
		try {
			test.checkIntegrity();
		} catch (IntegrityException e) {
			System.out.println("Integrity-test failed: " + e.getMessage());
			System.exit(1);
		}
		
		System.out.println("Integrity-test succeed.");
		System.exit(0);
	}
}
